import request from '@/utils/request'

/**
 * 获取部门列表
 */
export const reqGetDepartments = () => {
  return request({
    method: 'get',
    url: '/company/department'
  })
}

/**
 * 根据id删除部门
 * @param {*} id 部门id
 */
export const reqDelDepartment = (id) => {
  return request({
    method: 'delete',
    url: '/company/department/' + id
  })
}

/**
 * 添加部门(注意需要五个字段, pid)
 */
export const reqAddDepartment = (form) => {
  return request({
    method: 'post',
    url: '/company/department',
    data: form
  })
}

/**
 * 根据id查询部门详情
 */
export const reqGetDepartDetail = (id) => {
  return request({
    method: 'get',
    url: '/company/department/' + id
  })
}

/**
 * 根据id更新部门信息
 * @param {*} form form一定要有id
 */
export const reqUpdateDepartDetail = (form) => {
  return request({
    method: 'put',
    url: '/company/department/' + form.id,
    data: form
  })
}
